package vip.liux.backend.application.service.point;

import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import vip.liux.application.dots.ListResultDto;
import vip.liux.contracts.shared.enums.Status;
import vip.liux.contracts.shared.enums.point.PointRuleType;

import java.math.BigDecimal;
import java.time.Duration;

// 积分规则管理接口
public interface PointsRuleService {

    /**
     * 创建积分规则
     */
    PointsRuleDto createRule(PointsRuleCreateDto dto);

    /**
     * 修改积分规则
     */
    PointsRuleDto updateRule(Long id, PointsRuleCreateDto dto);

    /**
     * 启用/禁用规则
     */
    void toggleRuleStatus(Long ruleId, Status enable);


    PointsRuleDto detailRule(String ruleCode);

    /**
     * 获取积分规则下拉列表
     *
     * @return 积分规则下拉列表
     */
    ListResultDto<PointsRuleDto> list();

    // 规则创建 Dto
    @Getter
    @Setter
    class PointsRuleCreateDto {
        @NotBlank(message = "规则名称不能为空")
        private String ruleName;

        @NotBlank(message = "规则编码不能为空")
        private String ruleCode;

        @NotNull(message = "规则类型不能为空")
        private PointRuleType ruleType;

        private Duration validDuration;

        @NotNull(message = "每日上限不能为空")
        @DecimalMin(value = "0.01", message = "每日上限必须大于0")
        private BigDecimal dailyLimit; // 每日上限

        @NotNull(message = "状态不能为空")
        private Status status;
    }
}